using BuildingBlocks.Abstractions.Permissions;
using Identity.Application.PermissionKeyResourceIds.Interfaces;
using Identity.Application.PermissionKeyResourceIds.Queries;
using MediatR;

namespace Identity.Application.PermissionKeyResourceIds.QueryHandlers;

public class GetAllPermissionKeyResourceIdQueryHandler : IRequestHandler<GetAllPermissionKeyResourceIdQuery, List<PermissionBindingDto>>
{
    private readonly IApiPermissionBindingReadService _permissionKeyResourceIdReadService;
    public GetAllPermissionKeyResourceIdQueryHandler(IApiPermissionBindingReadService permissionKeyResourceIdReadService)
    {
        _permissionKeyResourceIdReadService = permissionKeyResourceIdReadService;
    }

    public async Task<List<PermissionBindingDto>> Handle(GetAllPermissionKeyResourceIdQuery request, CancellationToken cancellationToken)
    {
        var permissionBinding = await _permissionKeyResourceIdReadService.GetBindingsAsync(null, cancellationToken);
        return permissionBinding.ToList();
    }


}